# -*- coding: utf-8 -*-
# @Date：2024/7/19 10:10:11
# @Author：CJiaの青姝
# @FileName：cj_error
# @Editor：PyCharm2024
# @Remark：

def handle_server_error(server_error):
    """
    统一处理server异常
    :param server_error: 接口服务
    :return:
    """
    @server_error.exception_handler(Exception)
    def a(request, exc):
        if hasattr(exc, 'errno'):
            return server_error.create_response(request, data=[], msg=str(exc), code=exc.errno)
        else:
            return server_error.create_response(request, data=[], msg=str(exc), code=500)
